import 'package:flutter/material.dart';
import 'package:jd_app/config/apiConfig.dart';
import 'package:jd_app/model/homePage_model.dart';
import 'package:jd_app/net/net_request.dart';

class HomeProvider with ChangeNotifier {
  // HomePageModel? data;
  var data;
  bool isLoading = false;  
  bool isError = false;  
  String errMsg = '';
  loadHomeData() async {
      // var result = await NetRequest().request(url: ApiConfig.HOME_URL, method: 'get', queryParams: {
      //   "test": 1
      // });
      // if (result != null && result.code == 0) {
      //     print(result.data);
      // }
      isLoading = true;
      isError = false;  
      errMsg = '';
      NetRequest().request(url: ApiConfig.HOME_URL, method: 'get', queryParams: {
        "test": 1
      }).then((result) {
        isLoading = false;
        if (result != null && result.code == 0) {
           print(result.data);
          // data = result.data;
        };
        // print(data);
        notifyListeners();
      }).catchError((e) {
        isLoading = false;
        isError = true;
        errMsg = e.toString();
        print('error: $e');
        notifyListeners();
      });
  }
}